//
//  BK_SPS_List_Cell.m
//  bestkeep
//
//  Created by TOPTEAM on 2017/4/6.
//  Copyright © 2017年 utouu. All rights reserved.
//

#import "BK_SPS_List_Cell.h"
#import <Masonry.h>
#import "BK_OD_Color.h"
#import "BKUserStatusInfo.h"
@interface BK_SPS_List_Cell ()

@property (nonatomic,strong) UIView * view_back;
@property (nonatomic,strong) UILabel* lab_order;
@property (nonatomic,strong) UILabel* lab_DingDanHao;
@property (nonatomic,strong) UILabel* lab_timeSubmit;
@property (nonatomic,strong) UILabel* lab_time_submit;
@property (nonatomic,strong) UILabel* lab_typePay;
@property (nonatomic,strong) UILabel* lab_type_pay;


@end

@implementation BK_SPS_List_Cell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self){
        self.backgroundColor = [UIColor whiteColor];
        [self initView];
    }
    return self;
}

- (void)initView{
    
    
    /**
     * 背景View---白色
     */
    _view_back =[[UIView alloc]init];
    _view_back.backgroundColor=[UIColor whiteColor];
    [self addSubview:_view_back];
    [_view_back mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mas_top).offset(0);
        make.left.equalTo(self.mas_left).offset(0);
        make.width.mas_equalTo(@(ScreenWidth));
        make.bottom.equalTo(self.mas_bottom);
    }];
    
    /**
     *  订单号
     */
    _lab_order = [UILabel new];
    _lab_order.textColor = kOrderMediumGrey1;
    _lab_order.numberOfLines = 2;
    _lab_order.backgroundColor = [UIColor clearColor];
    _lab_order.font = [UIFont systemFontOfSize:14];
    _lab_order.text = @"订单号： ";
    [self addSubview:_lab_order];
    [_lab_order mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).mas_offset(ApplicationBackGauge);
        make.top.equalTo(self.mas_top).mas_offset(10);
        make.height.mas_equalTo(25);
    }];
    
    _lab_DingDanHao = [UILabel new];
    _lab_DingDanHao.textColor = kOrderMediumGrey1;
    _lab_DingDanHao.numberOfLines = 2;
    _lab_DingDanHao.backgroundColor = [UIColor clearColor];
    _lab_DingDanHao.font = [UIFont systemFontOfSize:14];
    _lab_DingDanHao.text = @"加载中...";
    [self addSubview:_lab_DingDanHao];
    [_lab_DingDanHao mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_lab_order.mas_right).mas_offset(10);
        make.top.equalTo(_lab_order.mas_top).mas_offset(0);
        make.height.mas_equalTo(25);
    }];
    
    
    
    /**
     *  lab_time_submit;//下单时间
     */
    _lab_timeSubmit= [[UILabel alloc]initWithFrame:CGRectZero];
    _lab_timeSubmit.textColor = kOrderMediumGrey1;
    _lab_timeSubmit.text = @"下单时间：";
    _lab_timeSubmit.font = [UIFont systemFontOfSize:14];
    [self addSubview:_lab_timeSubmit];
    [_lab_timeSubmit mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_lab_order.mas_left).mas_offset(0);
        make.top.equalTo(_lab_DingDanHao.mas_bottom).mas_offset(2);
        make.height.mas_equalTo(25);
    }];
    
    _lab_time_submit = [UILabel new];
    _lab_time_submit.textColor = kOrderMediumGrey1;
    _lab_time_submit.numberOfLines = 1;
    _lab_time_submit.backgroundColor = [UIColor clearColor];
    _lab_time_submit.font = [UIFont systemFontOfSize:14];
    _lab_time_submit.text = @"加载中...";
    [self addSubview:_lab_time_submit];
    [_lab_time_submit mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_lab_DingDanHao.mas_left).mas_offset(0);
        make.top.equalTo(_lab_timeSubmit.mas_top).mas_offset(0);
        make.centerY.equalTo(_lab_timeSubmit.mas_centerY);
        make.height.mas_equalTo(25);
    }];
    
    
    
    /**
     *
     */
    _lab_typePay= [[UILabel alloc]initWithFrame:CGRectZero];
    _lab_typePay.textColor = kOrderMediumGrey1;
    _lab_typePay.text = @"支付方式：";
    _lab_typePay.font = [UIFont systemFontOfSize:14];
    [self addSubview:_lab_typePay];
    [_lab_typePay mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_lab_timeSubmit.mas_left).mas_offset(0);
        make.top.equalTo(_lab_timeSubmit.mas_bottom).mas_offset(2);
        make.height.mas_equalTo(25);
    }];
    
    
    _lab_type_pay = [UILabel new];
    _lab_type_pay.textColor = kOrderMediumGrey1;
    _lab_type_pay.numberOfLines = 1;
    _lab_type_pay.backgroundColor = [UIColor clearColor];
    _lab_type_pay.font = [UIFont systemFontOfSize:14];
    _lab_type_pay.text = @"加载中...";
    [self addSubview:_lab_type_pay];
    [_lab_type_pay mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_lab_DingDanHao.mas_left).mas_offset(0);
        make.top.equalTo(_lab_typePay.mas_top).mas_offset(0);
        make.centerY.equalTo(_lab_typePay.mas_centerY);
        make.height.mas_equalTo(25);
    }];
    
    
    
    

    
    
}



-(void)relayOutUIWithModel:(BK_SP_OD_Model *)model;{
    //        [---POST----Result----200--]:{"code":"","data":{"order_no":"20170410112346233229","store_address":"陕西省-西安市碑林区店","pay_amount":45,"pay_way":10,"create_time":"2017-04-10 11:23:45","pay_status":1,"discount_amount":0},"success":true,"msg":""}     --request.URL-->http://api.test.bestkeep.cn/store/getOrder?orderNo=20170410112346233229
    
    if (model) {
        _lab_DingDanHao.text = model.order_no;
        
        _lab_time_submit.text =model.create_time ;
        
        if ([[NSString stringWithFormat:@"%@",model.pay_way] integerValue]==10) {
            /*
             * 余额
             */
            _lab_type_pay.text = @"余额";
            
            
        }else if([[NSString stringWithFormat:@"%@",model.pay_way] integerValue]==20){
            /*
             * 支付宝
             */

            _lab_type_pay.text = @"支付宝";
            
        }else if([[NSString stringWithFormat:@"%@",model.pay_way] integerValue]==30){
            
            /*
             * 微信
             */
            _lab_type_pay.text = @"微信";

        }
        
    }
    
    
}



+(CGFloat)computeHeight:(id)data{
    BKUserStatusInfo * userStatusInfo =[BKUserStatusInfo currentUser];
    if ([userStatusInfo.vipFlag integerValue]==1) {
        /*
         * 如果是VIP
         */
        if (ScreenHeight>700) {//ip6P+
            return 276/2.0+170+(736-667);
        }else if(ScreenHeight>600){//ip6
            return 276/2.0+170;
        }else if(ScreenHeight>500){//ip5
            return 276/2.0+170+(568-667);
        }else{//ip4
            return 276/2.0;
        }
        
    }else{
        /*
         * 不是VIP
         */
        return 276/2.0;//ip6
        
        
    }

}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
